<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a="http://richfaces.org/a4j"
	template="/layout/template-base.xhtml" contentType="text/html"
	markupType="xhtml">

	<ui:define name="content">
		
		<ui:include src="/user.xhtml" />
		
		<h:form>
			<s:decorate template="/layout/content.xhtml">
				<a:outputPanel rendered="#{reunionesAction.listarReuniones}">
					<h:outputText value="#{messages['meetings.table.title']}"
						styleClass="title color-blue" />
					<rich:panel styleClass="panel border-color-blue">
						<rich:dataTable columnClasses="data-table-cell" id="meetingsTable"
							value="#{reunionesAction.reuniones}" styleClass="data-table"
							var="item" rows="10">
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{messages['meetings.table.meeting.date']}" />
								</f:facet>
								<h:outputText value="#{item.fecha}">
									<s:convertDateTime pattern="dd/MM/yyyy HH:mm" />
								</h:outputText>
							</rich:column>
							<rich:column filterBy="#{item.lugar}">
								<f:facet name="header">
									<h:outputText value="#{messages['meetings.table.meeting.place']}" />
								</f:facet>
								<s:div styleClass="long-text">
									<h:outputText value="#{item.lugar}" />
								</s:div>
							</rich:column>
							<rich:column filterBy="#{item.orden}">
								<f:facet name="header">
									<h:outputText value="#{messages['meetings.table.agenda']}" />
								</f:facet>
								<s:div styleClass="long-text">
									<h:outputText value="#{item.orden}" />
								</s:div>
							</rich:column>
							<rich:column rendered="#{usuario.perfil.administrador}">
								<f:facet name="header">
									<h:outputText value="#{messages['meetings.table.leaving.date']}" />
								</f:facet>
								<h:outputText value="#{item.baja}">
									<s:convertDateTime pattern="dd/MM/yyyy" />
								</h:outputText>
							</rich:column>
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{messages['meetings.table.actions']}" />
								</f:facet>
								<h:commandLink action="#{reunionesReport.acta()}" styleClass="no-border">
									<h:graphicImage value="/img/icons/16/report.png" alt="#{messages['meetings.actions.list']}" title="#{messages['meetings.actions.list']}" />
									<f:setPropertyActionListener target="#{reunionesReport.reunion}" value="#{item}" />
								</h:commandLink>
								<rich:spacer />
								<rich:spacer />
								<a:commandLink action="#{reunionesAction.convocar()}" styleClass="no-border" reRender="base" rendered="#{(not item.email or usuario.perfil.administrador) and reunionesAction.hoy lt item.fecha and item.baja == null}">
									<h:graphicImage value="/img/icons/16/send.png" alt="#{messages['meetings.actions.send']}" title="#{messages['meetings.actions.send']}" />
									<f:setPropertyActionListener target="#{reunionesAction.reunion}" value="#{item}" />
								</a:commandLink>
								<rich:spacer />
								<rich:spacer />
								<a:commandLink action="#{reunionesAction.editar()}" styleClass="no-border" 
									rendered="#{usuario.perfil.administrador or usuario.perfil.reunionesModificar}" reRender="base">
									<h:graphicImage value="/img/icons/16/edit.png" alt="#{messages['meetings.actions.edit']}" title="#{messages['meetings.actions.edit']}" />
									<f:setPropertyActionListener target="#{reunionesAction.reunion}" value="#{item}" />
								</a:commandLink>
								<rich:spacer />
								<rich:spacer />
								<a:commandLink action="#{reunionesAction.eliminar()}" styleClass="no-border" 
									rendered="#{(usuario.perfil.administrador or usuario.perfil.reunionesEliminar) and item.baja == null}" reRender="base">
									<h:graphicImage value="/img/icons/16/delete.png" alt="#{messages['meetings.actions.delete']}" title="#{messages['meetings.actions.delete']}" />
									<f:setPropertyActionListener target="#{reunionesAction.reunion}" value="#{item}" />
								</a:commandLink>
							</rich:column>
						</rich:dataTable>
					</rich:panel>
	
					<rich:datascroller for="meetingsTable" align="center"
						selectedStyleClass="border-color-blue color-blue"
						styleClass="top-margin" tableStyleClass="border-color-blue no-bg" />
				</a:outputPanel>
				<a:outputPanel rendered="#{reunionesAction.editarReunion}">
					<h:outputText value="#{messages['meetings.edit.data']}"
						styleClass="title color-green" />
					<h:panelGrid styleClass="panel border-color-green" columns="4">
						
						<h:outputText value="#{messages['meetings.edit.meeting.date']}" styleClass="color-green" />
						<rich:calendar value="#{reunionesAction.reunion.fecha}" datePattern="dd/MM/yyyy" rendered="#{not reunionesAction.reunion.email or usuario.perfil.administrador}" />
						<h:outputText value="#{reunionesAction.reunion.fecha}" rendered="#{reunionesAction.reunion.email and not usuario.perfil.administrador}">
							<s:convertDateTime pattern="dd/MM/yyyy" />
						</h:outputText>
						
						<h:outputText value="#{messages['meetings.edit.meeting.time']}" styleClass="color-green" />
						<h:panelGrid columns="3" rendered="#{not reunionesAction.reunion.email or usuario.perfil.administrador}">
							<h:selectOneMenu value="#{reunionesAction.hora}">
								<f:selectItems value="#{reunionesAction.horas}" />
							</h:selectOneMenu>
							<h:outputText value=":" />
							<h:selectOneMenu value="#{reunionesAction.minuto}">
								<f:selectItems value="#{reunionesAction.minutos}" />
							</h:selectOneMenu>
						</h:panelGrid>
						<h:outputText value="#{reunionesAction.reunion.fecha}" rendered="#{reunionesAction.reunion.email and not usuario.perfil.administrador}">
							<s:convertDateTime pattern="HH:mm" />
						</h:outputText>
						
						<h:outputText value="#{messages['meetings.edit.meeting.place']}" styleClass="color-green" />
						<h:inputText value="#{reunionesAction.reunion.lugar}" rendered="#{not reunionesAction.reunion.email or usuario.perfil.administrador}" />
						<h:outputText value="#{reunionesAction.reunion.lugar}" rendered="#{reunionesAction.reunion.email and not usuario.perfil.administrador}" />
						
					</h:panelGrid>
					<s:div styleClass="clear-it" />
					
					<h:outputText value="#{messages['meetings.edit.agenda']}"
						styleClass="title color-orange" />
					<h:panelGrid styleClass="panel border-color-orange" columns="1">
						<h:inputTextarea value="#{reunionesAction.reunion.orden}" rendered="#{not reunionesAction.reunion.email or usuario.perfil.administrador}" />
						<h:inputTextarea value="#{reunionesAction.reunion.orden}" disabled="true" rendered="#{reunionesAction.reunion.email and not usuario.perfil.administrador}" />
					</h:panelGrid>
					<s:div styleClass="clear-it" />
					
					<h:outputText value="#{messages['meetings.edit.agreements']}"
						styleClass="title color-pink" rendered="#{reunionesAction.reunion.email or usuario.perfil.administrador}" />
					<h:panelGrid styleClass="panel border-color-pink" columns="1" rendered="#{reunionesAction.reunion.email or usuario.perfil.administrador}">
						<h:inputTextarea value="#{reunionesAction.reunion.acuerdos}" />
					</h:panelGrid>
					<s:div styleClass="clear-it" />
					
					<h:outputText value="#{messages['meetings.edit.comments']}"
						styleClass="title color-blue" rendered="#{reunionesAction.reunion.email or usuario.perfil.administrador}" />
					<h:panelGrid styleClass="panel border-color-blue" columns="1" rendered="#{reunionesAction.reunion.email or usuario.perfil.administrador}">
						<h:inputTextarea value="#{reunionesAction.reunion.observaciones}" />
					</h:panelGrid>
					<s:div styleClass="clear-it" />
					
					<h:outputText value="#{messages['meetings.users.table.title']}"
						styleClass="title color-green" rendered="#{reunionesAction.reunion.email or usuario.perfil.administrador}" />
					<rich:panel styleClass="panel border-color-green" rendered="#{reunionesAction.reunion.email or usuario.perfil.administrador}">
						<rich:dataTable columnClasses="data-table-cell" id="sociosTable"
							value="#{reunionesAction.usuarios}" styleClass="data-table"
							var="item" rows="7">
							<rich:column filterBy="#{item.nombre} #{item.primerApellido} #{item.segundoApellido}">
								<f:facet name="header">
									<h:outputText value="#{messages['meetings.users.table.name']}" />
								</f:facet>
								<h:outputText value="#{item.nombre} #{item.primerApellido} #{item.segundoApellido}" />
							</rich:column>
							<rich:column filterBy="#{item.dni}">
								<f:facet name="header">
									<h:outputText value="#{messages['meetings.users.table.id.number']}" />
								</f:facet>
								<h:outputText value="#{item.dni}" />
							</rich:column>
							<rich:column filterBy="#{item.email}">
								<f:facet name="header">
									<h:outputText value="#{messages['meetings.users.table.email']}" />
								</f:facet>
								<h:outputText value="#{item.email}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{messages['meetings.users.table.actions']}" />
								</f:facet>
								<h:selectBooleanCheckbox value="#{reunionesAction.seleccionados[item]}">
									<a:support action="#{reunionesAction.checkUsuario(item)}" event="onchange" reRender="usersPanel" />
								</h:selectBooleanCheckbox>
							</rich:column>
						</rich:dataTable>
					</rich:panel>
	
					<rich:datascroller for="sociosTable" align="center" selectedStyleClass="border-color-green color-green" 
						styleClass="top-margin" tableStyleClass="border-color-green no-bg" 
						rendered="#{reunionesAction.reunion.email or usuario.perfil.administrador}" />
					
				</a:outputPanel>
	
				<div class="clear-it"></div>
			</s:decorate>
			
			<s:decorate template="/layout/buttonbar.xhtml">
				<a:commandButton value="#{messages['meetings.actions.new']}" actionListener="#{reunionesAction.nueva()}"
					styleClass="btn btn-green" rendered="#{(usuario.perfil.administrador or usuario.perfil.reunionesCrear) and reunionesAction.listarReuniones}" reRender="base" />
				<a:commandButton value="#{messages['meetings.actions.save']}" actionListener="#{reunionesAction.guardar('meetings.info.save.success')}" styleClass="btn btn-green" 
					rendered="#{(usuario.perfil.administrador or usuario.perfil.reunionesCrear) and reunionesAction.editarReunion and reunionesAction.reunion.id == null}" reRender="base" />
				<a:commandButton value="#{messages['meetings.actions.save.changes']}" actionListener="#{reunionesAction.guardar('meetings.info.edit.success')}" styleClass="btn btn-green" 
					rendered="#{(usuario.perfil.administrador or usuario.perfil.reunionesModificar) and reunionesAction.editarReunion and reunionesAction.reunion.id != null}" reRender="base" />
				<a:commandButton value="#{messages['meetings.actions.cancel']}" styleClass="btn btn-orange" reRender="base"
					rendered="#{reunionesAction.editarReunion}" actionListener="#{reunionesAction.volver()}" />
				<h:commandButton value="#{messages['meetings.actions.back']}"
					action="/menu.htm" styleClass="btn btn-blue" />
			</s:decorate>
		</h:form>
	</ui:define>
	
</ui:composition>
